home *** CD-ROM | disk | FTP | other *** search
- //bird flap shader
- //1 directional light and ambient light applied
- //Luke Lenhart
- //(C)2004-2005 Digipen Institute of Technology
-
- //combined world,view,projection transform
- float4x4 matWorldViewProj;
-
- //1 directional light
- float4 l1Direction;
- float4 l1Color;
- float4 lAmbient;
-
- //current time (in seconds) since whenever
- float time;
-
- //shader input
- struct VS_INPUT
- {
- float4 Pos : POSITION;
- float4 Normal : NORMAL;
- float2 Tex0 : TEXCOORD0;
- };
-
- //shader output
- struct VS_OUTPUT
- {
- float4 Pos : POSITION;
- float4 Color : COLOR;
- float2 Tex0 : TEXCOORD0;
- };
-
- //shader code
- VS_OUTPUT VShader(VS_INPUT In)
- {
- VS_OUTPUT Out;
-
- //calc colors from directional light
- float4 l1Contrib=dot(-In.Normal,l1Direction)*l1Color;
- l1Contrib=saturate(l1Contrib);
- Out.Color=l1Contrib + lAmbient;
- Out.Color.a=1;
-
- //oscillate position based on distance from the middle axis, to make the wing flap
- float4 pos=In.Pos;
- pos.z+=sin(time)*abs(In.Pos.y);
-
- //do world/view/project transform
- Out.Pos=mul(matWorldViewProj,pos);
-
- //copy texture coord through
- Out.Tex0=In.Tex0;
-
- //spit out the results
- return Out;
- }
-